<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: _filter.phtml 4127 2010-07-30 07:25:47Z huuphuoc $
 * @since		2.0.0
 */
?>
<?php if (count($this->users) == 0) : ?>
	<?php echo $this->translator('user_list_not_found'); ?>	
<?php else : ?>
<?php foreach ($this->users as $user) : ?>
<div id="userRow_<?php echo $user->user_id; ?>" class="clearfix t_a_ui_data_list_content">
	<div class="grid_8 alpha">
		<div><?php echo $user->user_name; ?></div>
		
		<div class="t_a_top t_a_ui_helper_action">
			<a href="<?php echo $this->url(array('user_id' => $user->user_id), 'core_user_edit'); ?>"><?php echo $this->translator('user_list_action_edit'); ?></a> | 
			
			<a href="<?php echo $this->url(array('user_id' => $user->user_id), 'core_rule_set_user'); ?>"><?php echo $this->translator('user_list_action_rule'); ?></a>
			
			<?php if ($user->user_name != $this->currentUser) : ?>
			| <a class="activateAction" rel="<?php echo $user->user_id; ?>_<?php echo (int)$user->is_active; ?>_<?php echo $user->user_name; ?>" href="javascript: void(0);" onclick="javascript: activateUser(this);"><?php if ($user->is_active) : ?><?php echo $this->translator('user_list_action_deactivate'); ?><?php else : ?><?php echo $this->translator('user_list_action_activate'); ?><?php endif; ?></a>
			<?php endif; ?>
			
			<?php if($this->allow('delete')):?>
			| <a class="deleteAction" rel="<?php echo $user->user_id; ?>" href="javascript: void(0);"><?php echo $this->translator('user_list_action_delete'); ?></a>
			<?php endif; ?>
		</div>
	</div>

	<div class="grid_3"><?php echo $user->email; ?></div>
	
	<div class="grid_1 omega"><?php echo $user->user_id; ?></div>
</div>
<?php endforeach; ?>

<div class="t_a_bottom t_a_ui_paginator">
	<?php echo $this->paginator()->slide($this->paginator, $this->paginatorOptions); ?>
</div>
<?php endif; ?>
<script type="text/javascript">
$(document).ready(function() {
	/**
	* Delete user
	* @since: 2.0.8
	* @author: quanvo
	*/
	<?php if ($this->allow('delete')) : ?>
    $('a.deleteAction').click(function() {
        var self = this;
        $('#confirmDialog').html('<?php echo addslashes($this->translator('user_list_action_delete_confirm')); ?>')
            .dialog({
                title: '<?php echo addslashes($this->translator('common_dialog_confirm')); ?>',
                dialogClass: 't_a_ui_dialog',
                modal: true,
                closeOnEscape: false,
                resizable: false,
                open: function(event, ui) {
                    $('.ui-dialog-titlebar-close').hide();
                    $(this).parent().find('.ui-dialog-buttonpane button').wrapInner('<span/>');
                },
                buttons: {
                    '<?php echo addslashes($this->translator('common_dialog_confirm_no')); ?>': function() {
                        $(this).dialog('destroy');
                    },
                    '<?php echo addslashes($this->translator('common_dialog_confirm_yes')); ?>': function() {
                        $(this).dialog('destroy');
                        $(self).html('').addClass('t_a_ui_helper_loading');
                        var id = $(self).attr('rel');                        
                        $.ajaxq('user', {
                            type: 'POST',
                            url: "<?php echo $this->url(array(), 'core_user_delete'); ?>",
                            data: { id: id },
                            success: function(response) {
                                if ('RESULT_OK' == response) {                                	
                                    $('#userRow_' + id).fadeOut('slow');
                                }                                
                                /*else if('RESULT_IS_USED' == response) {
                                    $(self).removeClass('t_a_ui_helper_loading').append($('<span/>').html('<?php echo addslashes($this->translator('attribute_list_action_delete')); ?>'));
                                    $('#messageDialog').html('<?php echo addslashes($this->translator('attribute_list_action_not_deleteable')); ?>')
                                    .dialog({
                                        title: '<?php echo addslashes($this->translator('common_dialog_message')); ?>',
                                        dialogClass: 't_a_ui_dialog',
                                        modal: true,
                                        show: { effect: 'fade' },
                                        open: function(event, ui) {
                                            setTimeout(function() {
                                                $('#' + event.target.id).dialog('option', 'hide', 'fade').dialog('destroy');
                                            }, 3000);
                                        }
                                    });
                                }*/
                            }
                        });
                    }
                }
            });
    });
    <?php endif; ?>	
});
</script>